package com.easytrain.app;

import com.easytrain.app.R;
import com.easytrain.app.Util;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.app.Activity;
import android.content.Intent;

public class Main extends Activity {

	private LinearLayout priceSearch;
	private LinearLayout leftSearch;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		AppManager.getAppManager().addActivity(this);
		
		initListener();
	}
	
	private void initListener(){
		priceSearch = (LinearLayout)findViewById(R.id.main_price_search);
		priceSearch.setOnClickListener(priceSearchClickListener);
		leftSearch = (LinearLayout)findViewById(R.id.main_left_search);
		leftSearch.setOnClickListener(leftSearchClickListener);
	}
	
	private View.OnClickListener priceSearchClickListener = new View.OnClickListener(){
		public void onClick(View v) {
			Intent intent = new Intent(Main.this, PriceSearch.class);
	        startActivity(intent);
	        overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);	
		}
	};
	
	private View.OnClickListener leftSearchClickListener = new View.OnClickListener(){
		public void onClick(View v) {
			Util.ToastMessage(Main.this, "test ....");
		}
	};
	
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		boolean flag = true;
		if(keyCode == KeyEvent.KEYCODE_BACK){
			Util.Exit(this);
		}else if(keyCode == KeyEvent.KEYCODE_MENU){

		}else if(keyCode == KeyEvent.KEYCODE_SEARCH){

		}else{
			flag = super.onKeyDown(keyCode, event);
		}
		return flag;
	}

}
